<template>
	<view>
		<web-view :src="pdfUrl"></web-view>
	</view>
</template>

<script>
let wv;//计划创建的webview
	export default {
		data() {
			return {
				pdfUrl:'',
				from:''
			}
		},
    onLoad:function(option) {
      // this.pdfUrl= "/static/hybrid/html/web/viewer.html?file=./compressed.tracemonkey-pldi-09.pdf" //测试用的pdf
      console.log("PDF地址"+JSON.stringify(option.pdfUrl))
      if(this.util.isNotEmpty(option.pdfUrl)){
        this.pdfUrl= "/static/hybrid/html/web/viewer.html?file="+encodeURIComponent(option.pdfUrl)
      }else{
        this.$toast.fail('打开pdf文件失败，文件链接不能为空!')
        //返回到上一页
        /*uni.navigateBack({
          animationType: 'pop-out',
          animationDuration: 2000
        })*/
      }
    },
      onReady() {
        // #ifdef APP-PLUS
        var currentWebview = this.$scope.$getAppWebview() //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效
        setTimeout(function() {
          wv = currentWebview.children()[0]
          wv.setStyle({top:150,height:300})
        }, 1000); //如果是页面初始化调用时，需要延时一下
        // #endif
      },
		methods: {

		}
	}
</script>

<style>

</style>
